package com.lenovo.utils;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Properties;

public class PropertiesUtil {

    public static Properties properties = new Properties();

    /**
     * 根据文件名加载配置文件到inputStream
     *
     * @param fileName 文件名
     */
    static void loadFile(String fileName) {
        try {
            InputStream inputStream = PropertiesUtil.class.getClassLoader().getResourceAsStream(fileName);
            properties.load(new InputStreamReader(inputStream));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 根据键获得值
     *
     * @param key
     * @return
     */
    public static String getPropertyValue(String key) {
        return properties.getProperty(key);
    }

}